# -*- makefile -*-
# vi:se ft=make:

#OPT_SHARED_FLAGS                  += $(call CHECKCC,-finline-limit=10000,)
CROSS_COMPILE_DFL-$(CONFIG_BIT32) := arm-linux-gnueabihf-
CROSS_COMPILE_DFL-$(CONFIG_BIT64) := aarch64-linux-gnu-
CROSS_COMPILE                     ?= $(CROSS_COMPILE_DFL-y)
SHARED_FLAGS-$(CONFIG_ARM_PXA)    += -mcpu=xscale
SHARED_FLAGS-$(CONFIG_ARM_SA)     += -mcpu=strongarm1100
SHARED_FLAGS-$(CONFIG_ARM_920T)   += -mcpu=arm920t
SHARED_FLAGS-$(CONFIG_ARM_926)    += -mcpu=arm926ej-s
SHARED_FLAGS-$(CONFIG_ARM_1136)   += -mcpu=arm1136jf-s
SHARED_FLAGS-$(CONFIG_ARM_1176)   += -mcpu=arm1176jzf-s
SHARED_FLAGS-$(CONFIG_ARM_MPCORE) += -mcpu=mpcore
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_A5) += $(call CHECKCC,-mcpu=cortex-a5)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_A7) += $(call CHECKCC,-mcpu=cortex-a7,-mcpu=cortex-a9)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_A8) += $(call CHECKCC,-mcpu=cortex-a8)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_A9) += $(call CHECKCC,-mcpu=cortex-a9)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_A15) += $(call CHECKCC,-mcpu=cortex-a15,-mcpu=cortex-a9)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_A35) += $(call CHECKCC,-mcpu=cortex-a35,-march=armv8-a)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_A53) += $(call CHECKCC,-mcpu=cortex-a53,-march=armv8-a)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_A55) += $(call CHECKCC,-mcpu=cortex-a55,-march=armv8-a)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_A57) += $(call CHECKCC,-mcpu=cortex-a57,-march=armv8-a)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_A72) += $(call CHECKCC,-mcpu=cortex-a72,-march=armv8-a)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_A73) += $(call CHECKCC,-mcpu=cortex-a73,-march=armv8-a)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_A76) += $(call CHECKCC,-mcpu=cortex-a76,-march=armv8-a)
SHARED_FLAGS-$(CONFIG_ARM_NEOVERSE_N1) += $(call CHECKCC,-mcpu=neoverse-n1,-march=armv8.2-a)
SHARED_FLAGS-$(CONFIG_ARM_KRAIT) += $(call CHECKCC,-mcpu=krait,-mcpu=cortex-a15)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_R52) += $(call CHECKCC,-mcpu=cortex-r52,-march=armv8-r)
SHARED_FLAGS-$(CONFIG_ARM_CORTEX_R82) += $(call CHECKCC,-mcpu=cortex-r82,-march=armv8-a) # armv8-r only supported starting with GCC-11
SHARED_FLAGS-$(CONFIG_BIT32)      += $(if $(CC_IS_CLANG),,-Wno-psabi)
SHARED_FLAGS-$(CONFIG_BIT32)      += -mfloat-abi=soft
SHARED_FLAGS-$(CONFIG_BIT32)      += $(call CHECKCC,-masm-syntax-unified)
SHARED_FLAGS-$(CONFIG_BIT32)      += $(call CHECKCC,-mno-thumb-interwork)
SHARED_FLAGS-$(CONFIG_BIT32)      += $(if $(CONFIG_THUMB2),-mthumb -Xassembler -mimplicit-it=always,-marm) -mabi=aapcs
SHARED_FLAGS-$(CONFIG_BIT64)      += -mgeneral-regs-only
SHARED_FLAGS-$(CONFIG_BIT64)      += $(call CHECKCC,-mno-outline-atomics)
LDFLAGS-$(CONFIG_BIT32)           += --no-warn-mismatch
LDFLAGS                           += $(LDFLAGS-y)
LD_EMULATION_CHOICE-$(CONFIG_BIT32) := armelf armelf_linux_eabi armelf_fbsd
LD_EMULATION_CHOICE-$(CONFIG_BIT64) := aarch64linux aarch64elf
LD_EMULATION_CHOICE := $(LD_EMULATION_CHOICE-y)
OBJCOPY_BFDNAME-$(CONFIG_BIT32)   := elf32-littlearm
OBJCOPY_BFDNAME-$(CONFIG_BIT64)   := elf64-littleaarch64
OBJCOPY_BFDNAME                   := $(OBJCOPY_BFDNAME-y)
OBJCOPY_BFDARCH-$(CONFIG_BIT32)   := arm
OBJCOPY_BFDARCH-$(CONFIG_BIT64)   := aarch64
OBJCOPY_BFDARCH                   := $(OBJCOPY_BFDARCH-y)
